package com.opslab.util;


import org.apache.log4j.Logger;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

public class OpslabConfig {
    public static Logger logger = Logger.getLogger(OpslabConfig.class);


    public static Map<String, String> INIT_MAP = new HashMap();

    static {
        try {

            logger.error("正在加载配置...");

            INIT_MAP.put("HOST_FEATURE", "0001");
            INIT_MAP.put("DATETIME_FORMAT", "yyyy-MM-dd HH:mm:ss");
            INIT_MAP.put("DATE_FORMAT", "yyyy-MM-dd");
            INIT_MAP.put("TIME_FORMAT", "HH:mm:ss");
            INIT_MAP.put("mail.smtp.host", "smtp.qq.com");
            INIT_MAP.put("mail.smtp.port", "25");
            INIT_MAP.put("mail.smtp.auth", "true");
            INIT_MAP.put("mail.sender.username", "932135831@qq.com");
            INIT_MAP.put("mail.sender.password", "xuqiming");
            INIT_MAP.put("FTPTest.host", "135.224.9.67");
            INIT_MAP.put("FTPTest.port", "21");
            INIT_MAP.put("FTPTest.username", "ftptest");
            INIT_MAP.put("FTPTest.password", "ftptest");
            INIT_MAP.put("FTPTest.remoteDir", "./test");
            INIT_MAP.put("FTPTest.localDir", "c:/download");
            INIT_MAP.put("FTPTest.Encoding", "gbk");
            INIT_MAP.put("FTPTest.passiveMode", "true");


//            //获取非jar包内的配置信息
//            try {
//                String config_file = new File(contextClassLoader.getResource("0opslab.properties").toURI()).getPath();
//                Map<String, String> CONFIG_MAP = PropertiesUtil.GetAllProperties(config_file);
//                INIT_MAP.putAll(CONFIG_MAP);
//            } catch (Exception e) {
//            }

        } catch (Exception e) {
            logger.error("init config error:" + e.getMessage());
        }
//        System.out.println(CLASS_PATH);
//        System.out.println(CollectionHelper.join(INIT_MAP, "\n", ":"));
    }


    /*主机特征码*/
    public static final String HOST_FEATURE = INIT_MAP.get("HOST_FEATURE");

    /*日期时间类型格式*/
    public static final String DATETIME_FORMAT = INIT_MAP.get("DATETIME_FORMAT");

    /*日期类型格式*/
    public static final String DATE_FORMAT = INIT_MAP.get("DATE_FORMAT");

    /*时间类型的格式*/
    public static final String TIME_FORMAT = INIT_MAP.get("TIME_FORMAT");

    /**
     * 获取配置信息
     * @param key
     * @return
     */
    public static String get(String key){
        return INIT_MAP.get(key);
    }

    public static void main(String[] args) {
    }
}
